Repository navigation
socket: decode receive timestamps on a 32-bit system with a 64-bit time_t - #516
Open
WiFiGUY512 wants to merge 1 commit into
Open
WiFiGUY512 wants to merge 1 commit into
WiFiGUY512 wants to merge 1 commit into
Conversation
…me_t
musl names one SO_TIMESTAMP and one SO_TIMESTAMPNS, with no _OLD and
_NEW variants, and on a 32-bit system they are the kernel's _NEW values
(63 and 64 on ARM), whose control messages carry 64-bit fields. Without
SO_TIMESTAMP_NEW, the _NEW decoders were left out and the _OLD fallbacks,
defined to SO_TIMESTAMP and SO_TIMESTAMPNS, decoded those messages with
the old layout: tv_sec from the low half of the 64-bit seconds and the
fraction from the high half, which is 0. Every receive timestamp came
out in whole seconds.
Build the 64-bit-field decoders on every Linux system. Where the libc
names both variants, keep an entry for each; where it names only one,
decode it with the layout its time_t gives: the 64-bit fields where
time_t is wider than long. Also give st_timeval_new its own size; it had
the size of the old struct.
Seen on an Arista W-118 (IPQ4019, armv7, musl): SO_TIMESTAMP gave
{ sec, usec: 0 } and SO_TIMESTAMPNS { sec, nsec: 0 } for every packet.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Christopher Griffin <christophergriffin05@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On a 32-bit system with a 64-bit
time_tand musl, everySO_TIMESTAMPandSO_TIMESTAMPNSreceive timestamp reaches the script in whole seconds:{ sec, usec: 0 }and{ sec, nsec: 0 }.musl names a single
SO_TIMESTAMPandSO_TIMESTAMPNS, with no_OLDand_NEWvariants, and on a 32-bit system they are the kernel's_NEWvalues (63 and 64 on ARM), whose control messages carry 64-bit fields. WithoutSO_TIMESTAMP_NEWthe_NEWdecoders are compiled out, and the_OLDfallbacks (defined toSO_TIMESTAMPandSO_TIMESTAMPNSsince #491) decode those messages with the old{ long, long }layout:tv_secfrom the low half of the 64-bit seconds and the fraction from the high half, which is 0.This builds the 64-bit-field decoders on every Linux system. Where the libc names both variants, each keeps its entry; where it names only one, that one is decoded with the layout its
time_tgives. It also givesst_timeval_newits own size; it had the size of the old struct.Tested
{ sec, usec: 615067 }and{ sec, nsec: 616156570 }, where it gave 0 before.{ sec, usec }and type 35{ sec, nsec }, with fractions, as before.🤖 Generated with Claude Code